# File: hw3_2.py
# This program outputs the reverse complement of a DNA string

print 'Enter path to file containing DNA string:'

# Ask for path to file containing DNA string
# and load DNA string into memory
dna = open(raw_input(), 'U').read()

print "Enter name of output string:"

# Ask under what name to store output string
# and create output file
output = open(raw_input(), 'w')

# Determine length of DNA string
dna_size = len(dna)

# Go through the DNA string in reverse order
# and write to file the complement of each base pair
while dna_size > 0:
    if dna[dna_size-1] == 'g' or dna[dna_size-1] == 'G':
        output.write('c')
    elif dna[dna_size-1] == 'c' or dna[dna_size-1] == 'C':
        output.write('g')
    elif dna[dna_size-1] == 'a' or dna[dna_size-1] == 'A':
        output.write('t')
    elif dna[dna_size-1] == 't' or dna[dna_size-1] == 'T':
        output.write('a')
    else:
        output.write(dna[dna_size-1])
    dna_size -= 1
